/**
 * 
 */
package componentEnhancement;

import java.math.BigDecimal;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import cii_lib.CIIdata;

/**
 * @author pdrabik
 *
 */
public class Scaler {
	
	private static final Logger log = LoggerFactory.getLogger(Scaler.class);

	private CIIdata referenceData;
	private BigDecimal bigBase;
	private String parser;
	
	private long referenceValue = Integer.MAX_VALUE;
	
	public Scaler() {
		parser="1:0";
	}
	
	public CIIdata parseValue(CIIdata data) {
		referenceData=data;
		BigDecimal bigd = new BigDecimal(data.GetValue());
		BigDecimal ref = new BigDecimal(referenceValue);
		double tmp = bigd.divide(ref,BigDecimal.ROUND_HALF_DOWN).doubleValue();
		CIIdata ctmp = new CIIdata(data.GetWidth());
		log.debug("scal: "+ tmp+"="+" "+bigd.longValue()+"/" +ref.longValue());
		ctmp.SetValue((long)tmp);
		return ctmp;
	}
	
	
	public CIIdata getReference() {
		return referenceData;
	}
	public void setReference(CIIdata reference) {
		this.referenceData = reference;
	}

	public long getReferenceValue() {
		return referenceValue;
	}

	public void setReferenceValue(long referenceValue) {
		this.referenceValue = referenceValue;
	}
	
	
	
}
